﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AjaxControlToolkit;

public partial class Front_Suggest_Business : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {

          
        }
    }
    //private void Page_PreRender()
    //{
    //    this.ViewState["CaptchaImageText"] = RandomString.GenerateRandomCode().ToLower();
    //    CaptchaImage ci = new CaptchaImage(this.ViewState["CaptchaImageText"].ToString(), 200, 50, "Century Schoolbook");
    //    ci.Image.Save(Server.MapPath("images") + "/captchaImage.jpg");
    //    imgCaptcha.ImageUrl = "images/captchaImage.jpg";
    //    ci.Dispose();
    //}
    //protected void ImageCheck(object source, ServerValidateEventArgs args)
    //{

    //    if (!ViewState["CaptchaImageText"].ToString().ToLower().Equals(txtVerificationCode.Text.ToLower()))
    //    {
    //        ViewState.Remove("CaptchaImageText");
    //        // txtVerificationCode.Text = "";
    //        args.IsValid = false;
    //        return;
    //    }
    //    //txtVerificationCode.Text = "";
    //    ViewState.Remove("CaptchaImageText");

    //}

    protected void btnSuggestion_Click(object sender, EventArgs e)
    {

        var sug = new DealesDataContext();
        var query = sug.Insert_Suggestion(txtEmailID.Text, txtBusinessName.Text, txtContactName.Text, txtContactNumber.Text, txtDescription.Text, txtCity.Text);

        System.Collections.Specialized.ListDictionary replacements = new System.Collections.Specialized.ListDictionary();
        replacements.Add("<%NameOfBusiness%>", txtBusinessName.Text.ToString());
        replacements.Add("<%ContactName%>", txtContactName.Text.ToString());
        replacements.Add("<%ContactNumber%>", txtContactNumber.Text.ToString());
        replacements.Add("<%Description%>", txtDescription.Text.ToString());
        replacements.Add("<%Email%>", txtEmailID.Text.ToString());
        replacements.Add("<%Location%>", txtCity.Text.ToString());
        System.Net.Mail.MailMessage confirmation = Mailer.CreateMessage(new System.Web.UI.Control() as WebControl,
            Mailer.MessageTemplate.Suggestion, replacements, "ranjana.lanetteam@yahoo.com", "Suggestion");
        Mailer.InternalSend(confirmation, false);
        System.Net.Mail.MailMessage confirmation1 = Mailer.CreateMessage(new System.Web.UI.Control() as WebControl,
          Mailer.MessageTemplate.SuggestionUser, replacements, txtEmailID.Text.ToString(), "Suggestion");
        Mailer.InternalSend(confirmation, false);
        txtBusinessName.Text = "";
        txtContactName.Text = "";
        txtContactNumber.Text = "";
        txtDescription.Text = "";
        txtEmailID.Text = "";
        txtCity.Text = "";
        //txtVerificationCode.Text = "";
        lblMsg.Text = "Thanks for your suggestion.Your Suggestion is sent to the admin";
        
    }
}
